﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Model
{
    [ObjectEvent]
    public class CharactorCardComponentEvent : ObjectEvent<CharactorCardComponent>, IAwake
    {
        public void Awake()
        {
            Get().Awake();
        }
    }
    public class CharactorCardComponent : CardUseComponent, ICardUse,IIfCardUse
    {
        public CharactorType charactorType;

        public override string UseInfo { get; set; } = CardUseWay.UseAsCharactorCard;

        public override void Use(FightModel fightModel, BattlePlayer user)
        {
            BattleStatus battleStatus = fightModel.BattleStatus;
            if (battleStatus == BattleStatus.Change)
            {
                if (baseCard.CardPlace == CardPlace.Hand)
                {
                    user[CardPlace.Hand].MoveCards(user[CardPlace.Charactor], new List<BattleCard>() { baseCard });
                    baseCard.IfStand = false;
                    baseCard.IfRightSide = true;
                    Log.Debug($"{baseCard.CardGroup}进入support状态");
                }
                else if (baseCard.IfCenter)
                {
                    baseCard.Move(user[CardPlace.Duel_Charactor]);
                    Log.Debug($"{baseCard.CardGroup}进入hyper状态");
                }
                else if (baseCard.IfSupport)
                {
                    foreach (var card in user[CardPlace.Charactor].Cards)
                        card.IfStand = false;
                    baseCard.IfStand = true;
                    Log.Debug($"{baseCard.CardGroup}进入center状态");
                }
                //fightModel.NextStatus(fightModel.nowPlayer);//切换状态后自动进入下一阶段
            }
        }

        public override bool IfUse(FightModel fightModel, BattlePlayer user)
        {
            if (user != fightModel.nowPlayer) return false;
            BattleStatus battleStatus = fightModel.BattleStatus;
            if (battleStatus == BattleStatus.Change)
                if (baseCard.CardPlace == CardPlace.Hand)
                {
                    return true;
                }
                if (baseCard.CardPlace == CardPlace.Charactor)
                {
                    return true;
                }
            /*if (battleStatus == BattleStatus.Set && baseCard.CardPlace == CardPlace.Hand)
            {
                return true;
            }*/
            return false;
        }
    }
}
